package windbell.domain.risk.events;

import edu.fudan.langlab.domain.document.IDocument;
import edu.fudan.mylang.pf.event.EntityEventsManager;
import java.util.Collection;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import windbell.domain.risk.RiskCheckItem;
import windbell.domain.risk.RiskReport;
import windbell.domain.risk.events.RiskCheckItemEventsListener;

@Service("windbell.domain.risk.events.RiskCheckItemEventsManager")
public class RiskCheckItemEventsManager extends EntityEventsManager<RiskCheckItem> {
  @Autowired(required = false)
  private Collection<RiskCheckItemEventsListener> listeners = com.google.common.collect.Lists.newArrayList();;
  
  protected Collection<RiskCheckItemEventsListener> getListeners() {
    return listeners;
  }
  
  public void firePublish(final RiskCheckItem entity) {
    for (edu.fudan.mylang.pf.event.IEntityEventsListner<?> listener : listeners) {
    	((RiskCheckItemEventsListener)listener).publish(entity);
    }
    
  }
  
  public void fireStartAudit(final RiskCheckItem entity) {
    for (edu.fudan.mylang.pf.event.IEntityEventsListner<?> listener : listeners) {
    	((RiskCheckItemEventsListener)listener).startAudit(entity);
    }
    
  }
  
  public void fireCreateReport(final RiskCheckItem entity, final Procedure1<? super RiskReport> init) {
    for (edu.fudan.mylang.pf.event.IEntityEventsListner<?> listener : listeners) {
    	((RiskCheckItemEventsListener)listener).createReport(entity,init);
    }
    
  }
  
  public void fireDeleteReport(final RiskCheckItem entity, final RiskReport report) {
    for (edu.fudan.mylang.pf.event.IEntityEventsListner<?> listener : listeners) {
    	((RiskCheckItemEventsListener)listener).deleteReport(entity,report);
    }
    
  }
  
  public void fireCreateDocument(final RiskCheckItem entity, final Procedure1<? super IDocument> init) {
    for (edu.fudan.mylang.pf.event.IEntityEventsListner<?> listener : listeners) {
    	((RiskCheckItemEventsListener)listener).createDocument(entity,init);
    }
    
  }
  
  public void fireRemoveDocument(final RiskCheckItem entity, final IDocument document) {
    for (edu.fudan.mylang.pf.event.IEntityEventsListner<?> listener : listeners) {
    	((RiskCheckItemEventsListener)listener).removeDocument(entity,document);
    }
    
  }
  
  public void fireFinish(final RiskCheckItem entity, final String comment) {
    for (edu.fudan.mylang.pf.event.IEntityEventsListner<?> listener : listeners) {
    	((RiskCheckItemEventsListener)listener).finish(entity,comment);
    }
    
  }
}
